package com.zzyl.nursing.controller.member;

import java.util.List;

import com.zzyl.nursing.dto.AddFamilyMemberDto;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.vo.LoginVo;
import com.zzyl.nursing.vo.MemberVo;
import com.zzyl.nursing.vo.MyMemberVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.nursing.service.IFamilyMemberService;

/**
 * 老人家属Controller
 * 
 * @author ruoyi
 * @date 2025-08-26
 */
@RestController
@RequestMapping("/member/user")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;

    @PostMapping("/login")
    public AjaxResult login(@RequestBody UserLoginRequestDto userLoginRequestDto){
        LoginVo loginVo = familyMemberService.login(userLoginRequestDto);
        return success(loginVo);

    }
    // 绑定家人
    @PostMapping("/add")
    public AjaxResult add(@RequestBody AddFamilyMemberDto dto){
        familyMemberService.add(dto);
        return success();
    }
    // 查看家人列表
    @GetMapping("/list-by-page")
    public AjaxResult selectElderList(){
        startPage();
        List<MemberVo> memberVos = familyMemberService.selectElderList();
        return success(memberVos);
    }

    // 查询家人列表
    @GetMapping("/my")
    public AjaxResult myMember(){
        List<MyMemberVo> myMemberVo = familyMemberService.getElderList();
        return success(myMemberVo);
    }

    @DeleteMapping("/deleteById")
    public AjaxResult deleteById(Long id){
        familyMemberService.deleteById(id);
        return success();
    }
}


